package fun.pengzh.gui.uicomponents;


import com.jfoenix.controls.JFXMasonryPane;
import com.jfoenix.controls.JFXScrollPane;
import com.jfoenix.effects.JFXDepthManager;
import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import org.datafx.controller.FXMLController;

import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;

@FXMLController(value = "/fxml/Sorting.fxml", title = "Sorting Algorithm")
public class SortingController {
    @FXML
    private ScrollPane scrollPane;
    @FXML
    private JFXMasonryPane masonryPane;

    @PostConstruct
    public void init() {
        List list = new ArrayList<Pane>();
        StackPane stackPane1 = new StackPane();
        stackPane1.setPrefWidth(10);
        stackPane1.setPrefHeight(50);
        stackPane1.setVisible(true);
        stackPane1.getChildren().addAll(new Rectangle(100, 100, Color.BLUE), new Label("Go!"));

        JFXDepthManager.setDepth(stackPane1, 1);
        StackPane stackPane2 = new StackPane();
        stackPane2.setPrefHeight(10);
        stackPane2.setPrefWidth(80);
        JFXDepthManager.setDepth(stackPane2, 2);


        list.add(stackPane1);
        list.add(stackPane2);

        masonryPane.getChildren().addAll(list);
        Platform.runLater(() -> scrollPane.requestLayout());
        JFXScrollPane.smoothScrolling(scrollPane);
    }
}
